<div class="contact">
	<div class="texthead">
    	<p>Merci de remplir le formulaire ci-dessous <br />afin que nous puissions traiter <span class="blue">votre demande dans les meilleurs délais.</span><br /><br /><span class="bluebig">Pour toute urgence, contactez-nous par téléphone au 01 45 35 72 26.</span>
    </div></p>
    <?php
		@$pro_name=$_REQUEST["pro_name"];
    ?>
    <div class="wrapper">		
		<form id="form" class="blocks" action="index.php?page=contact" method="post">
			<p>
				<label>Nom:</label>
				<input type="text" class="text" name="name" />
			</p>
            <p>
				<label>Prénom:</label>
				<input type="text" class="text" name="prenom" />
			</p>
			<p>
				<label>Nom produit:</label>
				<input type="text" class="text" name="product" value="<?php echo $pro_name;?>" />
			</p>
            <p>
				<label>Adresse:</label>
				<input type="text" class="text" name="adress" />
			</p>
			<p>
				<label>Code postal:</label>
				<input type="text" class="text" name="code" />
			</p>
            <p>
				<label>Ville:</label>
				<input type="text" class="text" name="ville" />
			</p>
			<p>
				<label>E-mail:</label>
				<input type="text" class="text" name="email" />
			</p>
			<p>
				<label>Téléphone:</label>
				<input type="text" class="text" name="phone" />
			</p>
			<p>
				<label>Fax:</label>
				<input type="text" class="text" name="fax" />
			</p>
			<p class="area">
				<label>Message:</label>
				<textarea class="textarea" name="message"></textarea>
			</p>
			<p>
				<label>&nbsp;</label>
				<input type="submit" class="btn" name="btnsubmit" value="Envoyer ma demande" />
			</p>
		</form>
	</div>
</div>
<?php
    if(isset($_POST["btnsubmit"]))
	{
		//change this to your email.
		$to = "yann.phirum1988@gmail.com";
		$from = "doorProject.fr";
		$subject = "doorProject.fr";
		
		$name_adm = $_POST["name"];
		$prénom_adm = $_POST["prenom"]; 
		$name_con=$name_adm ." ".$prénom_adm;
		$name="<b>Non:</b> ". $name_adm ." ".$prénom_adm;
		
		$product_adm= $_POST["product"];
		$product="<b>Produit:</b> ". $product_adm;
		
		$adress_adm= $_POST["adress"];
		$adress="<b>Adresse:</b> ". $adress_adm;
		
		$code_adm= $_POST["code"];
		$code="<b>Code:</b> ". $code_adm;
		
		$ville_adm= $_POST["ville"];
		$ville="<b>Ville:</b> ". $ville_adm;
		
		$email_adm= $_POST["email"];
		$email="<b>Email:</b> ". $email_adm;
		
		$phone_adm= $_POST["phone"];
		$phone="<b>Téléphone:</b> ". $phone_adm;
		
		$fax_adm= $_POST["fax"];
		$fax="<b>Fax:</b> ". $fax_adm;
		
		$message_adm= $_POST["message"];
		$message="<b>Message:</b> ". $message_adm;

				//begin of HTML message
				$message = ''.$name.'<br>'.$product.'<br>'.$adress.'<br>'.$code.'<br>'.$ville.'<br>'.$email.'<br>'.$phone.'<br>'.$fax.'<br>'.$message;
			   //end of message
				$headers  = "From: $from\r\n";
				$headers .= "Content-type: text/html\r\n";
			
				//options to send to cc+bcc
				//$headers .= "Cc: [email]maa@p-i-s.cXom[/email]";
				//$headers .= "Bcc: [email]email@maaking.cXom[/email]";
				
				// now lets send the email.
				$send_contact = mail($to, $subject, $message, $headers);
				if($send_contact){
					// insert contact to db
					$sql="INSERT INTO tbl_contact(name,pro_name,address,codePostal,ville,email,telephone,fax,message)
						 VALUES('$name_con','$product_adm','$adress_adm','$code_adm','$ville_adm','$email_adm','$phone_adm',
						 '$fax_adm','$message_adm')";
					$result=query($sql);
					if ($result)
					{
						errorMessage( "Votre contact envoyé avec succès ..!");

					}	
				}
				else {
					
					errorMessage( "Envoyer un mail invalide .....!");
				}	
	}
?>  